<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset="UTF-8">
	<title>百朋后台管理系统</title>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/demo.css">
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
</head>
<style type="text/css">
	.input 
	{
		border: 1px solid #eaeaea;
		background-color: #6d654e;
		color: #fff;
		text-align: center;
		padding: 0px 10px -1px;
		border-radius: 4px;
	}
</style>
<body>
	<div class="list_table">
		<?php
			if ($type == '1') 
			{
				$title = '已签约商户列表';
			}
			elseif ($type == '2') 
			{
				$title = '已解约商户列表';
			}
		?>
		<table id="list_table" title="<?php echo $title; ?>" style="width:100%;height:372px;" 
			data-options="
				rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:10,toolbar:'#tb'
			"
		>
			<thead>
				<tr>
					<th field="fac_name" width="18%" align="center">商户全称</th>
					<th field="fac_corporation_email" width="15%" align="center">商户账号</th>
					<th field="fac_account" width="10%" align="center">商户编号</th>
					<th field="separatetype" width="10%" align="center">服务分类</th>
					<th field="man_type" width="7%" align="center">经营类别</th>
					<th field="fac_contact" width="10%" align="center">联系人</th>
					<th field="fac_contactphone" width="10%" align="center">联系电话</th>
					<th field="fac_city" width="10%" align="center">城市</th>
					<th field="action" width="9%" align="center" formatter="formatAction">操作</th>
				</tr>
			</thead>
		</table>
	</div>

	<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript">
		$(function() 
		{
			var json = '{$json_list}';
			var array = JSON.parse(json);
			$('#list_table').datagrid({loadFilter:pagerFilter}).datagrid('loadData', array);
		});

		function formatAction(value,row,index) 
		{
			var a = '<input type="button" value="详情" class="input" onclick="signinfo_edit(01,'+row.id+');">';
			if (<?php echo $type; ?> == '1') 
			{
				var b = '<input type="button" value="解约" class="input" onclick="signed(2,'+row.id+');">';
			}
			else if (<?php echo $type; ?> == '2')
			{
				var b = '<input type="button" value="签约" class="input" onclick="signed(1,'+row.id+');">';
			}
			return a+b;
		}

		function signinfo_edit(shopby_id,id) 
		{
			window.parent.addTab('签约资料编辑','../../facilitator/facilitator/signinfo_edit?id='+shopby_id+'&facilitator_info_id='+id);
		}

		//	签约动作
		function signed(type,id) 
		{
			if (type == '1') 
			{
				var msg = "您确定重新签约该商户吗？\n\n请确认！";
			}
			else if (type == '2') 
			{
				var msg = "您确定要解约该商户审核吗？\n\n请确认！";
			}
			if (confirm(msg)==true) 
			{
				var url = "../../facilitator/facilitator/signed";
				$.ajax({
					type: "POST",
					async: true,
					data: {"type":type,"signedData":id},
					url: url,
					success: function(d) 
					{
						if (d == 1) 
						{
							window.location.reload();
						}
						else
						{
							alert('操作失败，请尝试重新操作或联系管理员！');
							window.history.back(); 
						}
					},
					error: function(e) 
					{
						alert(e);
					}
				});
			}
			else
			{
				return false;
			}
		}
	</script>
</body>
</html>